/***************************************************************************
 *   Copyright (C) 2008 by JBox systems
 *   gabi@shaargiora.co.il
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 ***************************************************************************/

#pragma once

#include <fstream>
#include <string>

// Old logging code. doesn't compile on mingw
/*
#include <boost/logging/format.hpp>

typedef boost::logging::logger_format_write< > log_type;

BOOST_DECLARE_LOG_FILTER(g_log_filter, boost::logging::filter::no_ts)
BOOST_DECLARE_LOG(g_l, log_type )

#define L_LOG BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() )

BOOST_DECLARE_LOG_FILTER(e_log_filter, boost::logging::filter::no_ts)
BOOST_DECLARE_LOG(e_l, log_type)

#define E_LOG BOOST_LOG_USE_LOG_IF_FILTER(e_l(), e_log_filter()->is_enabled())

void init_logs() ;

*/

class Logger {
	public:

		static void init(std::string path);

		static Logger& Instance() {
			static Logger logger;
			return logger;
		}

		std::ofstream& write() { return m_file; }

		static std::string path() { return m_path; }

	private:

		Logger();
		Logger(Logger const&);
		Logger& operator= (Logger const&);
		~Logger();

		static std::string m_path;
		std::ofstream m_file;
};

#define LOG(msg) Logger::Instance().write() << msg << std::endl;
